<?
/* 
monitors.status
bit [0] - is active
bit [1] - is error
bit [2] - is approved
bit [3] - is account limit exced (too many monitors)
*/
define("MONITOR_STATUS_IS_ACTIVE_MASK",			0x00000001);
define("MONITOR_STATUS_IS_ERROR_MASK",			0x00000002);
define("MONITOR_STATUS_IS_APPROVED_MASK",		0x00000004);
define("MONITOR_STATUS_IS_ACCOUNT_LIMIT_MASK",	0x00000008);




define("MONITOR_FREQUENCY_10SEC",	10);
define("MONITOR_FREQUENCY_1MIN",	60);
define("MONITOR_FREQUENCY_1HOUR",	3600);
define("MONITOR_FREQUENCY_DAILY",	1*24*3600);
define("MONITOR_FREQUENCY_BEWEEKLY",3*24*3600);
define("MONITOR_FREQUENCY_WEEKLY",	7*24*3600);
define("MONITOR_FREQUENCY_MONTHLY",	30*24*3600);
$g_monitor_frequency_map = array(
	//MONITOR_FREQUENCY_10SEC		=> "10 Sec",
	//MONITOR_FREQUENCY_1MIN		=> "1 Min",
	MONITOR_FREQUENCY_1HOUR		=> "Hourly",
	MONITOR_FREQUENCY_DAILY		=> "Daily",
	MONITOR_FREQUENCY_BEWEEKLY	=> "Be-weekly",
	MONITOR_FREQUENCY_WEEKLY	=> "Weekly",
	MONITOR_FREQUENCY_MONTHLY	=> "Monthly",
);



define("TRIGGER_TYPE_MASK",				0x000000ff);
define("TRIGGER_ANY_CHANGES",			0x00000000);
define("TRIGGER_ANY_WORD_FROM_LIST",	0x00000001);
define("TRIGGER_ALL_WORDS_FROM_LIST",	0x00000002);
define("TRIGGER_PHRASE",				0x00000003);
define("TRIGGER_REGEX",					0x00000004);
$g_trigger_type_map = array(
	TRIGGER_ANY_CHANGES			=> "Notify of any changes",
	TRIGGER_ANY_WORD_FROM_LIST	=> "Notify of additions/deletions of some words",
	TRIGGER_ALL_WORDS_FROM_LIST	=> "Notify of additions/deletions of all words",
	TRIGGER_PHRASE				=> "Notify of additions/deletions of phrase",
	TRIGGER_REGEX				=> "Regular Expression",
);


define("TRIGGER_FLAG_SEARCH_TEXT",			0x00010000);
define("TRIGGER_FLAG_IN_ADD_TEXT",			0x00000000);
define("TRIGGER_FLAG_IN_DEL_TEXT",			0x00010000);

define("TRIGGER_FLAG_SKIP_DIGITS",			0x00020000);
define("TRIGGER_FLAG_SKIP_SMALL_CHANGES",	0x00040000);

define("ALERT_FORMAT_PLAIN_TEXT",	0);
define("ALERT_FORMAT_HTML",			1);
$g_alert_format_map = array(
	ALERT_FORMAT_PLAIN_TEXT	=>	"Text/Plain",
	ALERT_FORMAT_HTML		=>	"HTML"
);
$g_email_content_type = $g_alert_format_map;


define("ALERT_TYPE_URL",			0x00000001);
define("ALERT_TYPE_CHANGES_SUMARY",	0x00000002);
define("ALERT_TYPE_ATTACHMENT",		0x00000100); 
define("ALERT_TYPE_RSS",			0x00010000);
define("ALERT_TYPE_ATOM",			0x00020000);
define("ALERT_TYPE_FEED",			ALERT_TYPE_RSS | ALERT_TYPE_ATOM);

$g_alert_type_map = array(
	ALERT_TYPE_CHANGES_SUMARY	=> "E-mail with changes summary",
                                 /*"E-mail with changes summary and link to page with changes highlighted"*/
	ALERT_TYPE_ATTACHMENT		=> "Attach highlighted changes to the e-mail",
	/*
	Free plan account:
	ALERT_TYPE_URL				=> "E-mail with link to changes summary",
	*/
);
$g_alert_type_map_feeds = array(
	ALERT_TYPE_RSS				=> "RSS",
	ALERT_TYPE_ATOM				=> "ATOM",
);
$g_alert_type_default = ALERT_TYPE_CHANGES_SUMARY;

/* Old version
$g_alert_type_map = array(
	ALERT_TYPE_URL				=> "Send link to the updates history with changes highlighted",
	ALERT_TYPE_ATTACHMENT		=> "Send attachment with changes highlighted",
	ALERT_TYPE_CHANGES_SUMARY	=> "Send changes summary in the e-mail body",
	ALERT_TYPE_RSS				=> "RSS",
	ALERT_TYPE_ATOM				=> "ATOM",
);
$g_alert_type_default = ALERT_TYPE_URL;
*/
 

define("CONTENT_TYPE_MASK",		0x0000ffff);
define("CONTENT_TYPE_UNKNOWN",	0x00000000);
define("CONTENT_TYPE_HTML",		0x00000001);
define("CONTENT_TYPE_XML",		0x00000002);
define("CONTENT_TYPE_RSS",		0x00010000);
define("CONTENT_TYPE_ATOM",		0x00020000);



/* ---------------------------------------- */
/* -----           ENCODINGS          ----- */
/* ---------------------------------------- */
$a = array();

/* ----- European languages ----- */
$a[] = "ASCII";

$aa = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16);
foreach  ($aa as $ext) $a[] = "ISO-8859-$ext";

$aa = array("R","U","RU");
foreach  ($aa as $ext) $a[] = "KOI8-$ext";

$aa = array(1250,1251,1252,1253,1254,1257);
foreach  ($aa as $ext) $a[] = "CP$ext";

$aa = array(850,866);
foreach  ($aa as $ext) $a[] = "CP$ext";

$aa = array("Roman","CentralEurope","Iceland","Croatian","Romania");
foreach  ($aa as $ext) $a[] = "Mac$ext";

$aa = array("Cyrillic","Ukraine","Greek","Turkish");
foreach  ($aa as $ext) $a[] = "Mac$ext";

$a[] = "Macintosh";

/* ----- Semitic languages ----- */

$aa = array(6,8);
foreach  ($aa as $ext) $a[] = "ISO-8859-$ext";

$aa = array(1255,1256);
foreach  ($aa as $ext) $a[] = "CP$ext";

$a[] = "CP862";

$aa = array("Hebrew","Arabic");
foreach  ($aa as $ext) $a[] = "Mac$ext";

/* ----- Japanese ----- */
$a[] = "CP862";
$a[] = "EUC-JP";
$a[] = "SHIFT_JIS";
$a[] = "CP932";
$a[] = "ISO-2022-JP";
$a[] = "ISO-2022-JP-2";
$a[] = "ISO-2022-JP-1";

/* ----- Chinese ----- */
$a[] = "EUC-CN";
$a[] = "HZ";
$a[] = "GBK";
$a[] = "GB18030";
$a[] = "EUC-TW";
$a[] = "BIG5";
$a[] = "CP950";
$a[] = "BIG5-HKSCS";
$a[] = "ISO-2022-CN";
$a[] = "ISO-2022-CN-EXT";

/* ----- Korean ----- */
$a[] = "EUC-KR";
$a[] = "CP949";
$a[] = "ISO-2022-KR";
$a[] = "JOHAB";

/* ----- Armenian ----- */
$a[] = "ARMSCII-8";

/* ----- Georgian ----- */
$a[] = "Georgian-Academy";
$a[] = "Georgian-PS";

/* ----- Tajik ----- */
$a[] = "KOI8-T";

/* ----- Thai ----- */
$a[] = "TIS-620";
$a[] = "CP874";
$a[] = "MacThai";

/* ----- Laotian ----- */
$a[] = "MuleLao-1";
$a[] = "CP1133";

/* ----- Vietnamese ----- */
$a[] = "VISCII";
$a[] = "TCVN";
$a[] = "CP1258";

/* ----- Platform specifics ----- */
$a[] = "HP-ROMAN8";
$a[] = "NEXTSTEP";

/* ----- Full Unicode ----- */
$a[] = "UTF-8";
$a[] = "UCS-2";
$a[] = "UCS-2BE";
$a[] = "UCS-2LE";
$a[] = "UCS-4";
$a[] = "UCS-4BE";
$a[] = "UCS-4LE";
$a[] = "UTF-16";
$a[] = "UTF-16BE";
$a[] = "UTF-16LE";
$a[] = "UTF-32";
$a[] = "UTF-32BE";
$a[] = "UTF-32LE";
$a[] = "UTF-7";
$a[] = "C99";
$a[] = "JAVA";

/* ----------------------------------------------------------------- */
/* -----    Full Unicode, in terms of uint16_t or uint32_t     ----- */
/* -----   (with machine dependent endianness and alignment)   ----- */
/* ----------------------------------------------------------------- */
$a[] = "UCS-2-INTERNAL";
$a[] = "UCS-4-INTERNAL";


/* ----- European languages ----- */
/*
$aa = array(437,737,775,852,853,855,857,858,860,861,863,865,869,1125);
foreach  ($aa as $ext) $a[] = "CP$ext";
*/


/* ------------------------------------------------------------------------- */
/* -----   When configured with the option --enable-extra-encodings,   ----- */
/* -----    it also provides support for a few extra encodings:        ----- */
/* ------------------------------------------------------------------------- */
/*
// ----- Semitic languages -----
$a[] = "CP864";

// ----- Japanese -----
$a[] = "EUC-JISX0213";
$a[] = "Shift_JISX0213";
$a[] = "ISO-2022-JP-3";

// ----- Turkmen -----
$a[] = "TDS565";

// ----- Platform specifics -----
$a[] = "RISCOS-LATIN1";
*/

$g_charset_map = array();
$g_charset_map[""] = "Auto-detect";
foreach ($a as $s) {
    $g_charset_map[$s] = $s;
}
/* ---------------------------------------- */
/* -----        ENCODINGS - END       ----- */
/* ---------------------------------------- */



// Colors for highlight
define("HLC_TEXT",	0x1);
define("HLC_BK",	0x2);
$g_hightlight_colors = array(
	-1 => array("None"),
	0xFFFFFF => array("White"),
	$g_hightlight_bk_color_default =
	0xFFFF00 => array("Yellow"),
	0x00FF00 => array("Bright Green"),
	0x00FFFF => array("Turquoise"),
	0xFF00FF => array("Pink"),
	0x0000FF => array("Blue"),

	0xFF0000 => array("Red"),
	0x000080 => array("Dark Blue"),
	0x008080 => array("Teal"),
	0x008000 => array("Green"),
	0x800080 => array("Violet"),

	0x800000 => array("Dark Red"),
	0x808000 => array("Dark Yellow"),
	0x808080 => array("Gray &shy; 50%"),
	0xC0C0C0 => array("Gray &shy; 25%"),
	$g_hightlight_font_color_default =
	0x000000 => array("Black"),
);


foreach($g_hightlight_colors as $k => $v)
{
	$f = isset($v[1]) ? $v[1] : 0;
	if ($f == 0) $f = HLC_TEXT | HLC_BK;
	
	if ($f & HLC_TEXT)	$g_hightlight_font_color_map[$k] = $v[0];
	if ($f & HLC_BK)	$g_hightlight_bk_color_map[$k] = $v[0];
}


$g_highlight_font_style_bold		= 0x01;
$g_highlight_font_style_italic		= 0x02;
$g_highlight_font_style_underline	= 0x04;
$g_highlight_font_style_strike		= 0x08;

$g_highlight_font_style_map = array(
	$g_highlight_font_style_bold		=> "bold",
	$g_highlight_font_style_italic		=> "italic",
	$g_highlight_font_style_underline	=> "underline",
	$g_highlight_font_style_strike		=> "strike",
);

$g_def_highlight_font_style			=
    0x00 /* None */;


$g_http_user_agent_type_map = array(
	0x0 => "W3M Monitor 1.0.0",
	0x1 => "Mozila IE 5.0",
	0x2 => "Custom"
);


define("DHL_TYPE_ALL_PAGE",               0x00000001);
define("DHL_TYPE_ONLY_CHANGES_SUMMARY",   0x00000002);


$g_view_max_size_list = array(
	5, 10, 20, 30, 40, 50, 100
);


define("TIME_AM",	0x0);
define("TIME_PM",	0x1);
define("TIME_AMPM_DIVIDER", 12 * 3600);
$g_am_pm_map = array(
	TIME_AM =>	"AM",
	TIME_PM =>	"PM",
);


$g_time_zone_information = array(
	array('h'=>-12, 'm'=>-0,  't'=>"Eniwetok, Kwajalein"),
	array('h'=>-11, 'm'=>-0,  't'=>"Midway Island, Samoa"),
	array('h'=>-10, 'm'=>-0,  't'=>"Hawaii"),
	array('h'=>-9,  'm'=>-0,  't'=>"Alaska"),
	array('h'=>-8,  'm'=>-0,  't'=>"Pacific Time (US & Canada); Tijuana"),
	array('h'=>-7,  'm'=>-0,  't'=>"Mountain Time (US & Canada)"),
	array('h'=>-7,  'm'=>-0,  't'=>"Arizona"),
	array('h'=>-6,  'm'=>-0,  't'=>"Saskatchewan"),
	array('h'=>-6,  'm'=>-0,  't'=>"Mexico City"),
	array('h'=>-6,  'm'=>-0,  't'=>"Central Time (US & Canada)"),
	array('h'=>-6,  'm'=>-0,  't'=>"Central America"),
	array('h'=>-5,  'm'=>-0,  't'=>"Indiana (East)"),
	array('h'=>-5,  'm'=>-0,  't'=>"Eastern Time (US & Canada)"),
	array('h'=>-5,  'm'=>-0,  't'=>"Bogota, Lima, Quito"),
	array('h'=>-4,  'm'=>-0,  't'=>"Santiago"),
	array('h'=>-4,  'm'=>-0,  't'=>"Caracas, La Paz"),
	array('h'=>-4,  'm'=>-0,  't'=>"Atlantic Time (Canada)"),
	array('h'=>-3,  'm'=>-30, 't'=>"Newfoundland"),
	array('h'=>-3,  'm'=>-0,  't'=>"Greenland"),
	array('h'=>-3,  'm'=>-0,  't'=>"Buenos Aires, Georgetown"),
	array('h'=>-3,  'm'=>-0,  't'=>"Brasilia"),
	array('h'=>-2,  'm'=>-0,  't'=>"Mid-Atlantic"),
	array('h'=>-1,  'm'=>-0,  't'=>"Cape Verde Is."),
	array('h'=>-1,  'm'=>-0,  't'=>"Azores"),
	array('h'=>+0,  'm'=>+0,  't'=>"Casablanca, Monrovia"),
	array('h'=>+0,  'm'=>+0,  't'=>"Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London"),
	array('h'=>+1,  'm'=>+0,  't'=>"Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna"),
	array('h'=>+1,  'm'=>+0,  't'=>"Belgrade, Bratislava, Budapest, Ljubljana, Prague"),
	array('h'=>+1,  'm'=>+0,  't'=>"Brussels, Copenhagen, Madrid, Paris"),
	array('h'=>+1,  'm'=>+0,  't'=>"Sarajevo, Skopje, Sofija, Vilnius, Warsaw, Zagreb"),
	array('h'=>+1,  'm'=>+0,  't'=>"West Central Africa"),
	array('h'=>+2,  'm'=>+0,  't'=>"Athens, Istanbul, Minsk"),
	array('h'=>+2,  'm'=>+0,  't'=>"Bucharest"),
	array('h'=>+2,  'm'=>+0,  't'=>"Cairo"),
	array('h'=>+2,  'm'=>+0,  't'=>"Harare, Pretoria"),
	array('h'=>+2,  'm'=>+0,  't'=>"Helsinki, Riga, Tallinn"),
	array('h'=>+2,  'm'=>+0,  't'=>"Jerusalem"),
	array('h'=>+3,  'm'=>+0,  't'=>"Baghdad"),
	array('h'=>+3,  'm'=>+0,  't'=>"Kuwait, Riyadh"),
	array('h'=>+3,  'm'=>+0,  't'=>"Moscow, St. Petersburg, Volgograd"),
	array('h'=>+3,  'm'=>+0,  't'=>"Nairobi"),
	array('h'=>+3,  'm'=>+30, 't'=>"Tehran"),
	array('h'=>+4,  'm'=>+0,  't'=>"Abu Dhabi, Muscat"),
	array('h'=>+4,  'm'=>+0,  't'=>"Baku, Tbilisi, Yerevan"),
	array('h'=>+4,  'm'=>+30, 't'=>"Kabul"),
	array('h'=>+5,  'm'=>+0,  't'=>"Ekaterinburg"),
	array('h'=>+5,  'm'=>+0,  't'=>"Islamabad, Karachi, Tashkent"),
	array('h'=>+5,  'm'=>+30, 't'=>"Calcutta, Chennai, Mumbai, New Delhi"),
	array('h'=>+5,  'm'=>+45, 't'=>"Kathmandu"),
	array('h'=>+6,  'm'=>+0,  't'=>"Almaty, Novosibirsk"),
	array('h'=>+6,  'm'=>+0,  't'=>"Astana, Dhaka"),
	array('h'=>+6,  'm'=>+0,  't'=>"Sri Jayawardenepura"),
	array('h'=>+6,  'm'=>+30, 't'=>"Rangoon"),
	array('h'=>+7,  'm'=>+0,  't'=>"Bangkok, Hanoi, Jakarta"),
	array('h'=>+7,  'm'=>+0,  't'=>"Krasnoyarsk"),
	array('h'=>+8,  'm'=>+0,  't'=>"Beijing, Chongqing, Hong Kong, Urumqi"),
	array('h'=>+8,  'm'=>+0,  't'=>"Irkutsk, Ulaan Bataar"),
	array('h'=>+8,  'm'=>+0,  't'=>"Kuala Lumpur, Singapore"),
	array('h'=>+8,  'm'=>+0,  't'=>"Perth"),
	array('h'=>+8,  'm'=>+0,  't'=>"Taipei"),
	array('h'=>+9,  'm'=>+0,  't'=>"Osaka, Sapporo, Tokyo"),
	array('h'=>+9,  'm'=>+0,  't'=>"Seoul"),
	array('h'=>+9,  'm'=>+0,  't'=>"Yakutsk"),
	array('h'=>+9,  'm'=>+30, 't'=>"Adelaide"),
	array('h'=>+9,  'm'=>+30, 't'=>"Darwin"),
	array('h'=>+10, 'm'=>+0,  't'=>"Brisbane"),
	array('h'=>+10, 'm'=>+0,  't'=>"Canberra, Melbourne, Sydney"),
	array('h'=>+10, 'm'=>+0,  't'=>"Guam, Port Moresby"),
	array('h'=>+10, 'm'=>+0,  't'=>"Hobart"),
	array('h'=>+10, 'm'=>+0,  't'=>"Vladivostok"),
	array('h'=>+11, 'm'=>+0,  't'=>"Magadan, Solomon Is., New Caledonia"),
	array('h'=>+12, 'm'=>+0,  't'=>"Auckland, Wellington"),
	array('h'=>+12, 'm'=>+0,  't'=>"Fiji, Kamchatka, Marshall Is."),
	array('h'=>+13, 'm'=>+0,  't'=>"Nuku'alofa"),
);

function timezone_offset_to_string($tz)
{
	$is_pos = ($tz >= 0);
	$tz = abs($tz);
	$h = (int)($tz / 3600);
	$m = (int)(($tz % 3600) / 60);

	$s = "(GMT";
	if ($h != 0 || $m != 0) {
		$s .= " ".
			($is_pos ? "+" : "-").
			str_pad($h, 2, "0", STR_PAD_LEFT).
			":".
			str_pad($m, 2, "0", STR_PAD_LEFT);
	}
	$s .= ")";
	return $s;
}

$g_timezone_map = array();
foreach ($g_time_zone_information as $info)
{
	$offs = $info['h'] * 3600 + $info['m'] * 60;

	$offs_key = $offs;
	while (isset($g_timezone_map[$offs_key])) {
		if ($offs_key >= 0) ++$offs_key; else --$offs_key;
	}
	
	$g_timezone_map[$offs_key] = timezone_offset_to_string($offs)." ".$info['t'];
}

?>